<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        function read() {
            var req;
            var v1 = document.getElementsByName("personnelcount");  //获取人员计数的text
            var v2 = document.getElementsByName("dustconcentration");//获取粉尘浓度的text
            var v3 = document.getElementsByName("pipelinewindpressure");//获取管道风压的text
            var xhr = new XMLHttpRequest();//创建对象
            url = "";
            xhr.open("post", url, true);  //配置
            //post:post请求
            //true: 是否为异步发送请求
            xhr.onreadystatechange = function ()  //检测状态是否发生变化
            {
                if (xhr.readyState === 4 && xhr.status === 200) {
                    req = xhr.responseText.split(" ");  //响应正文
                    v1[0].value = req[0];
                    v2[0].value = req[1] ;
                    v3[0].value = req[2] ;
                }
            }
            xhr.send("list");  //向网页服务器发送list
        }
        //选择用的哪个单选按钮
        function write_f(objid) {   
            var xhr = new XMLHttpRequest();//创建对象
            url = "";
            xhr.open("post", url, true);  //配置
            if (objid == 'fanon') {
                xhr.send("\"type=10key=104value=1\"");

            } else if (objid == 'fanoff') {
                xhr.send("\"type=10key=104value=0\"");

            }
            if (objid == 'ledon') {
                xhr.send("\"type=10key=105value=1\"");

            } else if (objid == 'ledoff') {
                xhr.send("\"type=10key=105value=0\"");

            }
            if (objid == 'valveon') {
                xhr.send("\"type=10key=106value=1\"");

            } else if (objid == 'valveoff') {
                xhr.send("\"type=10key=106value=0\"");

            }
            if (objid == 'alarmon') {
                xhr.send("\"type=10key=107value=1\"");

            } else if (objid == 'alarmoff') 
            {
                xhr.send("\"type=10key=107value=0\"");
            }
        }
    </script>
</head>

<body>
    <!-- checked="checked"  默认选择 -->
    信息采集<br>
    人员计数:<input type="text" name="personnelcount" value="内容"><br/>
    粉尘浓度:<input type="text" name="dustconcentration" value="内容"><br/>
    管道风压:<input type="text" name="pipelinewindpressure" value="内容"><br/>
    <input type="button" name="flash" value="刷新" onclick="read()">
    装备控制<br>

    通风扇
    <input type="radio" name="fan" id="fanon"  onclick="write_f(id)">
    on
    <input type="radio" name="fan" id="fanoff"  onclick="write_f(id)">
    off<br>
    LED灯
    <input type="radio" name="led" id="ledon"  onclick="write_f(id)">
    on
    <input type="radio" name="led" id="ledoff"  onclick="write_f(id)">
    off<br>
    阀门
    <input type="radio" name="valve" id="valveon" onclick="write_f(id)"> 
    on
    <input type="radio" name="valve" id="valveoff"  onclick="write_f(id)">
    off<br>
    报警器  
    <input type="radio" name="alarm" id="alarmon" onclick="write_f(id)"> 
    on
    <input type="radio" name="alarm" id="alarmoff"  onclick="write_f(id)">
    off<br>
</body>

</html>